package top.duorhs.jspider;

import lombok.Data;

import java.util.LinkedList;

/**
 * @author Duorhs
 * @date 2023/1/7 14:24
 */
@Data
public class PageNode {
    private String currentPage;

    private LinkedList<PageNode> childPages;

    public PageNode() {
        this.currentPage = "";
        this.childPages = new LinkedList<>();
    }

    public PageNode(String url) {
        this.currentPage = url;
        this.childPages = new LinkedList<>();
    }

    /**
     * 增加子节点
     *
     * @param childNode 网页内的子节点
     */
    public void addNode(PageNode childNode) {
        this.childPages.add(childNode);
    }

    /**
     * 增加子节点
     *
     * @param childNodes 网页内的子节点
     */
    public void addNodes(LinkedList<PageNode> childNodes) {
        this.childPages.addAll(childNodes);
    }

    public boolean hasChild() {
        return this.childPages.size() != 0;
    }
}
